<template>
	<z-container title="审核订单" :loading="state.loading">
		<view class="ss-p-x-32 ss-p-y-24 bg-white">
			<OrderShow :info="info" readOnly />
			<uv-textarea class="ss-m-t-24" height="268rpx" v-model="form.sh_remake" placeholder="请输入备注"></uv-textarea>
		</view>
		<uv-gap height="50"></uv-gap>
		<z-bottom :zIndex="99">
			<view class="ss-p-x-32 ss-p-y-16 ss-flex gap-24">
				<z-button class="ss-w-100" @tap="state.cancelTipsShow = !state.cancelTipsShow" plan borderColorMain>取消订单</z-button>
				<z-button class="ss-w-100" @tap="changeTipsShow">审核订单 ￥{{ info.all_price }}</z-button>
			</view>
		</z-bottom>
		<z-modaltips @confirm="confirmOrder" v-model="state.tipsShow" :content="state.tips"></z-modaltips>
		<CancelOrder :info="info" v-model="state.cancelTipsShow" />
	</z-container>
</template>

<script setup>
	import sheep from "@/sheep"
	import OrderShow from "@/pages/components/OrderShow.vue"
	import CancelOrder from "@/pages/components/CancelOrder.vue"
	const state = reactive({
		tipsShow: false,
		cancelTipsShow: false,
		cancelTips:'确认取消订单吗？',
		tips: "确认审核该订单吗，将不可再修改？",
		loading:true
	})
	const info = ref({})
	const form = reactive({
		order_id:'',
		sh_remake:''
	})
	onLoad(({id = ''}) => {
		state.id = id
		form.order_id = id
	})
	onShow(() => {
		getDetail()
	})
	function changeTipsShow(){
		state.tipsShow = !state.tipsShow
	}
	async function confirmOrder(){
		const { code,data } = await sheep.$api.user.she_order(form)
		if(code != 1) return
		setTimeout(() => {
			uni.$emit('onReachIndex')
			uni.$emit('onReachOrder')
			sheep.$router.back()
		},1000)
		// sheep.$router.go('/pages/order/checkDetail')
	}
	function confirmCancelOrder(){
		
	}
	async function getDetail(){
		const { code,data } = await sheep.$api.user.orderdetail({order_id:state.id})
		if(code != 1) return
		info.value = data
		state.loading = false
	}
</script>

<style>

</style>
